##### show feature and solver selection

library(BBmisc)
library(stringr)
library(plyr)
library(ggplot2)
library(xtable)

source("results_utils.R")
source("analyzeFeatSelResult.R")

res = load2("~/work/coseal/aslib-r/server_scripts/selection_results.RData")

tmp = load2("~/work/coseal/aslib-r/server_scripts/llama_results.RData")
res.llama = tmp$res
res.regrrf = subset(res.llama, algo == "regr" & model == "randomForest")
rownames(res.regrrf) = res.regrrf$prob

tab = data.frame()

for (j in 1:length(res)) {
  r = res[[j]]
  row = data.frame(
    scen = r$id, res.regrrf[r$id, "par10"],
    paste(length(r$solvs$x$x), sum(r$solvs$x$x), sep = " $\\to$ "),
    r$solvs$y,
    paste(length(r$feats$x$x), sum(r$feats$x$x), sep = " $\\to$ "),
    r$feats$y
  )
  tab = rbind(tab, row)
}
colnames(tab) = c("Scenario", "PAR10", "Number", "PAR10", "Number", "PAR10")

tab$Scenario = convertScenarioNames(tab$Scenario)
tab = tab[match(proborder, tab$Scenario), ]

sink(file = "results_selection.tex")
xt = xtable(tab, align = "llccccc")
print(xt, "latex", only.contents=TRUE, include.rownames = FALSE, floating = FALSE, booktabs = TRUE, sanitize.text.function=function(x){x})
sink(NULL)








